<html>
<head><meta charset="utf-8"><title>Adding Rust v0 demangling support to LLVM · general · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/index.html">general</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Adding.20Rust.20v0.20demangling.20support.20to.20LLVM.html">Adding Rust v0 demangling support to LLVM</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="201804436"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Adding%20Rust%20v0%20demangling%20support%20to%20LLVM/near/201804436" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Yifei Teng <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Adding.20Rust.20v0.20demangling.20support.20to.20LLVM.html#201804436">(Jun 24 2020 at 01:43)</a>:</h4>
<p>Hi! <span class="user-mention" data-user-id="130111">@anp</span> and I work on Rust and Fuchsia. We're hoping to get the much better Rust v0 symbol mangling format enabled, but most of the LLVM tooling only demangles C++/Itanium. <span class="user-mention" data-user-id="119009">@eddyb</span> have contributed v0 demangling to gcc/gdb, and maybe we could follow a similar procedure for upstreaming to LLVM?<br>
One of our LLVM contributors mentioned they'll be happy to help refactor the code to match LLVM style. Would like to hear your thoughts.</p>



<a name="201804956"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Adding%20Rust%20v0%20demangling%20support%20to%20LLVM/near/201804956" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> anp <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Adding.20Rust.20v0.20demangling.20support.20to.20LLVM.html#201804956">(Jun 24 2020 at 01:55)</a>:</h4>
<p>(not sure how i didn't get pinged, alas)</p>



<a name="201831229"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Adding%20Rust%20v0%20demangling%20support%20to%20LLVM/near/201831229" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Adding.20Rust.20v0.20demangling.20support.20to.20LLVM.html#201831229">(Jun 24 2020 at 10:17)</a>:</h4>
<p>Oh, did the libiberty patches land? Cool. Would be great to see some movement on this indeed :)</p>



<a name="202039509"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Adding%20Rust%20v0%20demangling%20support%20to%20LLVM/near/202039509" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Adding.20Rust.20v0.20demangling.20support.20to.20LLVM.html#202039509">(Jun 26 2020 at 00:00)</a>:</h4>
<p><span class="user-mention" data-user-id="211727">@Jonas Schievink</span> no, they did not</p>



<a name="202039572"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Adding%20Rust%20v0%20demangling%20support%20to%20LLVM/near/202039572" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Adding.20Rust.20v0.20demangling.20support.20to.20LLVM.html#202039572">(Jun 26 2020 at 00:00)</a>:</h4>
<p>and that's the main reason I haven't contributed it to anywhere else yet</p>



<a name="202039656"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Adding%20Rust%20v0%20demangling%20support%20to%20LLVM/near/202039656" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Adding.20Rust.20v0.20demangling.20support.20to.20LLVM.html#202039656">(Jun 26 2020 at 00:01)</a>:</h4>
<p>aww :(</p>



<a name="202039726"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Adding%20Rust%20v0%20demangling%20support%20to%20LLVM/near/202039726" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Adding.20Rust.20v0.20demangling.20support.20to.20LLVM.html#202039726">(Jun 26 2020 at 00:02)</a>:</h4>
<p><span class="user-mention" data-user-id="304321">@Yifei Teng</span> not sure the style matters, it's sort of designed to plug in as a 1-file mostly-C89 library. there's probably a lot of things that can be cleaned up going from that to e.g. LLVM C++, but it's probably in  the interest of future maintainability to leave it alone</p>



<a name="202039766"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Adding%20Rust%20v0%20demangling%20support%20to%20LLVM/near/202039766" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Adding.20Rust.20v0.20demangling.20support.20to.20LLVM.html#202039766">(Jun 26 2020 at 00:03)</a>:</h4>
<p>to get the GNU formatting style I used <code>clang-format</code>, and so we could just repeat that for a different style, that should work fine</p>



<a name="202039829"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Adding%20Rust%20v0%20demangling%20support%20to%20LLVM/near/202039829" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Yifei Teng <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Adding.20Rust.20v0.20demangling.20support.20to.20LLVM.html#202039829">(Jun 26 2020 at 00:04)</a>:</h4>
<p>Hi Eddy, thanks for getting back! Sorry I should've said coding style in the more general sense, besides the parts that could be fixed by a formatter.</p>



<a name="202039857"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Adding%20Rust%20v0%20demangling%20support%20to%20LLVM/near/202039857" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Adding.20Rust.20v0.20demangling.20support.20to.20LLVM.html#202039857">(Jun 26 2020 at 00:05)</a>:</h4>
<p>I'm curious what you have in mind, because, again, I'd rather not have more than 1 C implementation of this</p>



<a name="202039935"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Adding%20Rust%20v0%20demangling%20support%20to%20LLVM/near/202039935" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Yifei Teng <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Adding.20Rust.20v0.20demangling.20support.20to.20LLVM.html#202039935">(Jun 26 2020 at 00:05)</a>:</h4>
<p>Would you be okay with uploading a patch to the LLVM Phabricator? I can put you into contact with the LLVM devs on our team.</p>



<a name="202040006"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Adding%20Rust%20v0%20demangling%20support%20to%20LLVM/near/202040006" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Adding.20Rust.20v0.20demangling.20support.20to.20LLVM.html#202040006">(Jun 26 2020 at 00:06)</a>:</h4>
<p><span class="user-mention" data-user-id="304321">@Yifei Teng</span> <span class="user-mention" data-user-id="130111">@anp</span> oh the other thing is the copyright. while I wrote all of the new code, in order to incorporate the "legacy" support, I technically refactored the preexisting implementation, which is <span class="user-mention" data-user-id="119235">@David Tolnay</span>'s. not sure what the procedure is for dealing with that</p>



<a name="202040009"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Adding%20Rust%20v0%20demangling%20support%20to%20LLVM/near/202040009" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Yifei Teng <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Adding.20Rust.20v0.20demangling.20support.20to.20LLVM.html#202040009">(Jun 26 2020 at 00:06)</a>:</h4>
<p>I see, so there's value in keeping it unchanged for ease of future modifications</p>



<a name="202040043"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Adding%20Rust%20v0%20demangling%20support%20to%20LLVM/near/202040043" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Adding.20Rust.20v0.20demangling.20support.20to.20LLVM.html#202040043">(Jun 26 2020 at 00:07)</a>:</h4>
<p>yeah the goal is to mostly copy-paste it, the same way the legacy implementation is pretty much verbatim found in libiberty, linux-perf, valgrind, etc.</p>



<a name="202040062"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Adding%20Rust%20v0%20demangling%20support%20to%20LLVM/near/202040062" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Adding.20Rust.20v0.20demangling.20support.20to.20LLVM.html#202040062">(Jun 26 2020 at 00:07)</a>:</h4>
<p>as for phabricator: I hate using it, and I don't really have the time to do the integration/testing work right now</p>



<a name="202040278"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Adding%20Rust%20v0%20demangling%20support%20to%20LLVM/near/202040278" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Adding.20Rust.20v0.20demangling.20support.20to.20LLVM.html#202040278">(Jun 26 2020 at 00:10)</a>:</h4>
<p><span class="user-mention" data-user-id="304321">@Yifei Teng</span> anyway, what would be great if someone who hacks on LLVM more than I do, would try to hook up my code (<a href="https://gist.github.com/eddyb/c41a69378750a433767cf53fe2316768">https://gist.github.com/eddyb/c41a69378750a433767cf53fe2316768</a>) to LLVM, and talk to me about it (either here or PM)</p>



<a name="202040318"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Adding%20Rust%20v0%20demangling%20support%20to%20LLVM/near/202040318" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Yifei Teng <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Adding.20Rust.20v0.20demangling.20support.20to.20LLVM.html#202040318">(Jun 26 2020 at 00:11)</a>:</h4>
<p>I wonder if it could be made into a dedicated library, that could be imported into LLVM as a third-party dependency. This way we could avoid all the work to align to the LLVM style/testing IIUC</p>



<a name="202040331"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Adding%20Rust%20v0%20demangling%20support%20to%20LLVM/near/202040331" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Adding.20Rust.20v0.20demangling.20support.20to.20LLVM.html#202040331">(Jun 26 2020 at 00:11)</a>:</h4>
<p>what is a "library" in C :)?</p>



<a name="202040478"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Adding%20Rust%20v0%20demangling%20support%20to%20LLVM/near/202040478" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Adding.20Rust.20v0.20demangling.20support.20to.20LLVM.html#202040478">(Jun 26 2020 at 00:13)</a>:</h4>
<p>if you have an easy way to add a <code>.c</code> + <code>.h</code> pair as a "contrib" thing then this could be something offered in multiple licenses that LLVM can just use. but the way it was designed was "everyone copies from <code>libiberty</code>" and <code>libiberty</code> can't have "contrib" stuff AFAIK so I'm not entirely sure what the best way to do this is</p>



<a name="202040481"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Adding%20Rust%20v0%20demangling%20support%20to%20LLVM/near/202040481" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Yifei Teng <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Adding.20Rust.20v0.20demangling.20support.20to.20LLVM.html#202040481">(Jun 26 2020 at 00:13)</a>:</h4>
<p>Sure :) it would not be a library library, but as an example, Fuchsia imported musl which is a C library, and basically hooked it into the build system, without refactoring its code</p>



<a name="202040527"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Adding%20Rust%20v0%20demangling%20support%20to%20LLVM/near/202040527" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Yifei Teng <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Adding.20Rust.20v0.20demangling.20support.20to.20LLVM.html#202040527">(Jun 26 2020 at 00:14)</a>:</h4>
<p>I see. Yes, a .c + .h was what I was imagining</p>



<a name="202040541"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Adding%20Rust%20v0%20demangling%20support%20to%20LLVM/near/202040541" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Adding.20Rust.20v0.20demangling.20support.20to.20LLVM.html#202040541">(Jun 26 2020 at 00:14)</a>:</h4>
<p>in case you haven't looked: this is the entire thing <a href="https://gist.github.com/eddyb/c41a69378750a433767cf53fe2316768">https://gist.github.com/eddyb/c41a69378750a433767cf53fe2316768</a></p>



<a name="202040620"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Adding%20Rust%20v0%20demangling%20support%20to%20LLVM/near/202040620" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Adding.20Rust.20v0.20demangling.20support.20to.20LLVM.html#202040620">(Jun 26 2020 at 00:16)</a>:</h4>
<p><code>test.rs</code> can link against the C code and cross-compare its result with <code>rustc-demangle</code> (the Rust demangler implemented in Rust), for which I have a dataset of about 1 million symbols collected a while ago (from building rustc+Cargo)</p>



<a name="202040660"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Adding%20Rust%20v0%20demangling%20support%20to%20LLVM/near/202040660" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> alercah <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Adding.20Rust.20v0.20demangling.20support.20to.20LLVM.html#202040660">(Jun 26 2020 at 00:16)</a>:</h4>
<p>I'd hazard a guess that getting dtolnay to agree to relicense it would be easier than figuring out whether you can put LGPL code into LLVM.</p>



<a name="202040673"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Adding%20Rust%20v0%20demangling%20support%20to%20LLVM/near/202040673" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Adding.20Rust.20v0.20demangling.20support.20to.20LLVM.html#202040673">(Jun 26 2020 at 00:16)</a>:</h4>
<p>oh that's definitely what I had in mind</p>



<a name="202040688"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Adding%20Rust%20v0%20demangling%20support%20to%20LLVM/near/202040688" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Adding.20Rust.20v0.20demangling.20support.20to.20LLVM.html#202040688">(Jun 26 2020 at 00:16)</a>:</h4>
<p>I just don't know if it's as simple as asking <span class="user-mention" data-user-id="119235">@David Tolnay</span> or if someone has to dig into the history of the file in libiberty etc.</p>



<a name="202040715"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Adding%20Rust%20v0%20demangling%20support%20to%20LLVM/near/202040715" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> alercah <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Adding.20Rust.20v0.20demangling.20support.20to.20LLVM.html#202040715">(Jun 26 2020 at 00:17)</a>:</h4>
<p>oh that's just a question of how much risk you're willing to take :P</p>



<a name="202040769"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Adding%20Rust%20v0%20demangling%20support%20to%20LLVM/near/202040769" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Adding.20Rust.20v0.20demangling.20support.20to.20LLVM.html#202040769">(Jun 26 2020 at 00:18)</a>:</h4>
<p>where "you" isn't even me, is it :P?</p>



<a name="202040785"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Adding%20Rust%20v0%20demangling%20support%20to%20LLVM/near/202040785" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> alercah <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Adding.20Rust.20v0.20demangling.20support.20to.20LLVM.html#202040785">(Jun 26 2020 at 00:18)</a>:</h4>
<p>I hope it isn't</p>



<a name="202040996"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Adding%20Rust%20v0%20demangling%20support%20to%20LLVM/near/202040996" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Adding.20Rust.20v0.20demangling.20support.20to.20LLVM.html#202040996">(Jun 26 2020 at 00:21)</a>:</h4>
<p><span class="user-mention" data-user-id="304321">@Yifei Teng</span> anyway, yeah, if you can find someone to figure out the licensing situation and/or try to use it from LLVM, it'd be great :D</p>



<a name="202041072"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Adding%20Rust%20v0%20demangling%20support%20to%20LLVM/near/202041072" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> alercah <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Adding.20Rust.20v0.20demangling.20support.20to.20LLVM.html#202041072">(Jun 26 2020 at 00:22)</a>:</h4>
<p>pretty sure Google can figure that out :P</p>



<a name="202041088"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Adding%20Rust%20v0%20demangling%20support%20to%20LLVM/near/202041088" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Adding.20Rust.20v0.20demangling.20support.20to.20LLVM.html#202041088">(Jun 26 2020 at 00:22)</a>:</h4>
<p>I mean in their team or w/e</p>



<a name="202041106"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Adding%20Rust%20v0%20demangling%20support%20to%20LLVM/near/202041106" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> alercah <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Adding.20Rust.20v0.20demangling.20support.20to.20LLVM.html#202041106">(Jun 26 2020 at 00:22)</a>:</h4>
<p>yeah there's a whole department for stuff like this</p>



<a name="202041131"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Adding%20Rust%20v0%20demangling%20support%20to%20LLVM/near/202041131" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Adding.20Rust.20v0.20demangling.20support.20to.20LLVM.html#202041131">(Jun 26 2020 at 00:23)</a>:</h4>
<p>there's two APIs, <code>const char* -&gt; char*</code> and a callback based one. the callback one could probably be hooked up to anything stream-like (so you could demangle to an ostream, for example). but I don't know off the top of my head what LLVM (or parts of LLVM, I guess) want here</p>



<a name="202041407"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Adding%20Rust%20v0%20demangling%20support%20to%20LLVM/near/202041407" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Yifei Teng <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Adding.20Rust.20v0.20demangling.20support.20to.20LLVM.html#202041407">(Jun 26 2020 at 00:27)</a>:</h4>
<p>LLVM uses something similar to const char* -&gt; char*, IIUC, and has another mechanism to extract symbols from a stream</p>



<a name="202041537"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Adding%20Rust%20v0%20demangling%20support%20to%20LLVM/near/202041537" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Adding.20Rust.20v0.20demangling.20support.20to.20LLVM.html#202041537">(Jun 26 2020 at 00:29)</a>:</h4>
<p>the latter doesn't seem to be too relevant. to be clear, the callback API is for "printing on the fly" - the <code>const char* -&gt; char*</code> API uses the callback API where the callback is string concatenation</p>



<a name="202041595"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Adding%20Rust%20v0%20demangling%20support%20to%20LLVM/near/202041595" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Adding.20Rust.20v0.20demangling.20support.20to.20LLVM.html#202041595">(Jun 26 2020 at 00:30)</a>:</h4>
<p>(although I guess LLVM might want some kind of predicate for what looks like a Rust symbol name. that's one thing we could provide, I guess)</p>



<a name="202041988"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Adding%20Rust%20v0%20demangling%20support%20to%20LLVM/near/202041988" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Yifei Teng <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Adding.20Rust.20v0.20demangling.20support.20to.20LLVM.html#202041988">(Jun 26 2020 at 00:36)</a>:</h4>
<p>cc <span class="user-mention" data-user-id="199555">@Petr Hosek</span>  who has done lots of LLVM licensing</p>



<a name="202042099"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Adding%20Rust%20v0%20demangling%20support%20to%20LLVM/near/202042099" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Petr Hosek <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Adding.20Rust.20v0.20demangling.20support.20to.20LLVM.html#202042099">(Jun 26 2020 at 00:38)</a>:</h4>
<p>I can check with relevant people on the LLVM side and find out exactly what's needed.</p>



<a name="202154810"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Adding%20Rust%20v0%20demangling%20support%20to%20LLVM/near/202154810" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Petr Hosek <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Adding.20Rust.20v0.20demangling.20support.20to.20LLVM.html#202154810">(Jun 26 2020 at 23:24)</a>:</h4>
<p>I got the official response, what we need from <span class="user-mention" data-user-id="119009">@eddyb</span> and <span class="user-mention" data-user-id="119235">@David Tolnay</span> is to send an email to llvm-dev with the patch and make it clear that you expressly want to relicense it under LLVM license.</p>



<a name="202154825"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Adding%20Rust%20v0%20demangling%20support%20to%20LLVM/near/202154825" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Petr Hosek <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Adding.20Rust.20v0.20demangling.20support.20to.20LLVM.html#202154825">(Jun 26 2020 at 23:24)</a>:</h4>
<p>Here's an example from the recent history which did the same: <a href="http://lists.llvm.org/pipermail/cfe-dev/2020-May/065487.html">http://lists.llvm.org/pipermail/cfe-dev/2020-May/065487.html</a></p>



<a name="202154875"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Adding%20Rust%20v0%20demangling%20support%20to%20LLVM/near/202154875" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Adding.20Rust.20v0.20demangling.20support.20to.20LLVM.html#202154875">(Jun 26 2020 at 23:25)</a>:</h4>
<p>ah, great!</p>



<a name="202154891"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Adding%20Rust%20v0%20demangling%20support%20to%20LLVM/near/202154891" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Petr Hosek <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Adding.20Rust.20v0.20demangling.20support.20to.20LLVM.html#202154891">(Jun 26 2020 at 23:25)</a>:</h4>
<p>Once you do that, we can take the patch and handle the rest.</p>



<a name="202154972"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Adding%20Rust%20v0%20demangling%20support%20to%20LLVM/near/202154972" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Adding.20Rust.20v0.20demangling.20support.20to.20LLVM.html#202154972">(Jun 26 2020 at 23:26)</a>:</h4>
<p>it kinda sounds like it would be great if the code was already upstream somewhere :P</p>



<a name="202155002"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Adding%20Rust%20v0%20demangling%20support%20to%20LLVM/near/202155002" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Adding.20Rust.20v0.20demangling.20support.20to.20LLVM.html#202155002">(Jun 26 2020 at 23:26)</a>:</h4>
<p>not gonna lie, I really hate contributing to GCC. and it's only GCC because they keep libiberty's main copy there...</p>



<a name="202155140"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Adding%20Rust%20v0%20demangling%20support%20to%20LLVM/near/202155140" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Adding.20Rust.20v0.20demangling.20support.20to.20LLVM.html#202155140">(Jun 26 2020 at 23:28)</a>:</h4>
<p><span class="user-mention" data-user-id="199555">@Petr Hosek</span> btw, something else that would be useful is knowing if this API fits in readily, and if there are parts of the implementation that would not work inside LLVM <a href="https://gist.github.com/eddyb/c41a69378750a433767cf53fe2316768#file-demangle-h-L7-L9">https://gist.github.com/eddyb/c41a69378750a433767cf53fe2316768#file-demangle-h-L7-L9</a></p>



<a name="202155167"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Adding%20Rust%20v0%20demangling%20support%20to%20LLVM/near/202155167" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Adding.20Rust.20v0.20demangling.20support.20to.20LLVM.html#202155167">(Jun 26 2020 at 23:29)</a>:</h4>
<p>presumably all but two functions being <code>static</code> should absolve them of any requirement of namespacing, right?</p>



<a name="202155244"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Adding%20Rust%20v0%20demangling%20support%20to%20LLVM/near/202155244" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Adding.20Rust.20v0.20demangling.20support.20to.20LLVM.html#202155244">(Jun 26 2020 at 23:30)</a>:</h4>
<p>and namespacing just those two under <code>llvm::</code> or w/e should also be possible. something I haven't tried is compiling this as C++. I suspect it should work but I could be wrong</p>



<a name="202155551"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Adding%20Rust%20v0%20demangling%20support%20to%20LLVM/near/202155551" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Petr Hosek <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Adding.20Rust.20v0.20demangling.20support.20to.20LLVM.html#202155551">(Jun 26 2020 at 23:34)</a>:</h4>
<p>I think we'll have to make some changes to  use idiomatic C++, follow LLVM conventions, fit into existing conventions, etc. but I wouldn't worry about that, it's something we can handle.</p>



<a name="202155618"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Adding%20Rust%20v0%20demangling%20support%20to%20LLVM/near/202155618" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Adding.20Rust.20v0.20demangling.20support.20to.20LLVM.html#202155618">(Jun 26 2020 at 23:35)</a>:</h4>
<p>I'm definitely curious how automated the process is (like I said, I don't have it in me to do GNU style by hand, I was using <code>clang-format</code> for that part), and how big the changes are</p>



<a name="202155705"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Adding%20Rust%20v0%20demangling%20support%20to%20LLVM/near/202155705" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Adding.20Rust.20v0.20demangling.20support.20to.20LLVM.html#202155705">(Jun 26 2020 at 23:36)</a>:</h4>
<p>if there are significant (but not C++ specific) API changes I'd rather have them propagate everywhere than deal with a second wave of patches</p>



<a name="205314358"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Adding%20Rust%20v0%20demangling%20support%20to%20LLVM/near/205314358" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Petr Hosek <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Adding.20Rust.20v0.20demangling.20support.20to.20LLVM.html#205314358">(Jul 29 2020 at 03:13)</a>:</h4>
<p>To follow up on this, I cannot promise that future patches can be directly applied  because the changes needed to integrate this functionality cleanly into LLVM can't be done purely by reformatting the code, we'd really want to turn it into an idiomatic C++ and use LLVM's support libraries where possible.</p>



<a name="205314382"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Adding%20Rust%20v0%20demangling%20support%20to%20LLVM/near/205314382" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Petr Hosek <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Adding.20Rust.20v0.20demangling.20support.20to.20LLVM.html#205314382">(Jul 29 2020 at 03:14)</a>:</h4>
<p>However, I don't expect you to be on the hook for future updates, that's going to be our responsibility.</p>



<a name="207111888"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Adding%20Rust%20v0%20demangling%20support%20to%20LLVM/near/207111888" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Yifei Teng <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Adding.20Rust.20v0.20demangling.20support.20to.20LLVM.html#207111888">(Aug 17 2020 at 06:58)</a>:</h4>
<p><span class="user-mention" data-user-id="119009">@eddyb</span>  just a friendly follow up, it sounds like the C demangling library would have to be turned into C++/LLVM standard in order to upstream into LLVM, which is probably not exactly a trivial change. But the good news is the LLVM team should be able to take on that and implementing similar future changes you make to the library.</p>
<p>Would you be okay with emailing a patch to llvm-dev (referring Petr's message above) as-is? I think once discussion starts there the various interface and technical issues could be sorted out. Appreciate it very much :)</p>



<a name="207119768"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Adding%20Rust%20v0%20demangling%20support%20to%20LLVM/near/207119768" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Adding.20Rust.20v0.20demangling.20support.20to.20LLVM.html#207119768">(Aug 17 2020 at 08:49)</a>:</h4>
<p>ugh I'm not really comfortable with all of that. what is the point? why couldn't LLVM just treat it as an opaque dependency</p>



<a name="207119797"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Adding%20Rust%20v0%20demangling%20support%20to%20LLVM/near/207119797" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Adding.20Rust.20v0.20demangling.20support.20to.20LLVM.html#207119797">(Aug 17 2020 at 08:49)</a>:</h4>
<p>if you want a C++ version, you're better off converting the Rust implementation instead of the C one</p>



<a name="207119866"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Adding%20Rust%20v0%20demangling%20support%20to%20LLVM/near/207119866" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Adding.20Rust.20v0.20demangling.20support.20to.20LLVM.html#207119866">(Aug 17 2020 at 08:50)</a>:</h4>
<p>(since the C one works within the limitations of C and libiberty)</p>



<a name="207119913"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Adding%20Rust%20v0%20demangling%20support%20to%20LLVM/near/207119913" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Adding.20Rust.20v0.20demangling.20support.20to.20LLVM.html#207119913">(Aug 17 2020 at 08:51)</a>:</h4>
<p>although we should figure out the const encoding stuff first :/</p>



<a name="207119959"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Adding%20Rust%20v0%20demangling%20support%20to%20LLVM/near/207119959" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Adding.20Rust.20v0.20demangling.20support.20to.20LLVM.html#207119959">(Aug 17 2020 at 08:51)</a>:</h4>
<p>not sure if <span class="user-mention" data-user-id="124288">@oli</span> and/or I should spend time on that <em>now</em> to avoid dealing with more work later</p>



<a name="207120026"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Adding%20Rust%20v0%20demangling%20support%20to%20LLVM/near/207120026" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Adding.20Rust.20v0.20demangling.20support.20to.20LLVM.html#207120026">(Aug 17 2020 at 08:52)</a>:</h4>
<p>and also polymorphization might introduce some unforeseen consequences (cc <span class="user-mention" data-user-id="116107">@davidtwco</span>) wrt some assumptions we made with impls</p>



<a name="207129996"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Adding%20Rust%20v0%20demangling%20support%20to%20LLVM/near/207129996" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Adding.20Rust.20v0.20demangling.20support.20to.20LLVM.html#207129996">(Aug 17 2020 at 11:04)</a>:</h4>
<p>I am spending time on it</p>



<a name="207130001"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Adding%20Rust%20v0%20demangling%20support%20to%20LLVM/near/207130001" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Adding.20Rust.20v0.20demangling.20support.20to.20LLVM.html#207130001">(Aug 17 2020 at 11:04)</a>:</h4>
<p>it's just not a trivial conversion to do</p>



<a name="207131420"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Adding%20Rust%20v0%20demangling%20support%20to%20LLVM/near/207131420" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Adding.20Rust.20v0.20demangling.20support.20to.20LLVM.html#207131420">(Aug 17 2020 at 11:21)</a>:</h4>
<p>I guess lmk what I should look at/help with</p>



<a name="207131435"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Adding%20Rust%20v0%20demangling%20support%20to%20LLVM/near/207131435" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Adding.20Rust.20v0.20demangling.20support.20to.20LLVM.html#207131435">(Aug 17 2020 at 11:21)</a>:</h4>
<p>like we have to decide on an encoding and whatnot</p>



<a name="207131642"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Adding%20Rust%20v0%20demangling%20support%20to%20LLVM/near/207131642" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Adding.20Rust.20v0.20demangling.20support.20to.20LLVM.html#207131642">(Aug 17 2020 at 11:24)</a>:</h4>
<p><span class="user-mention" data-user-id="199555">@Petr Hosek</span> <span class="user-mention" data-user-id="304321">@Yifei Teng</span> if you want a C++ version, can you look at this and let me know what API you want? <a href="https://github.com/alexcrichton/rustc-demangle/blob/master/src/v0.rs">https://github.com/alexcrichton/rustc-demangle/blob/master/src/v0.rs</a></p>



<a name="207131666"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Adding%20Rust%20v0%20demangling%20support%20to%20LLVM/near/207131666" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Adding.20Rust.20v0.20demangling.20support.20to.20LLVM.html#207131666">(Aug 17 2020 at 11:24)</a>:</h4>
<p>this is similar to an output stream <a href="https://github.com/alexcrichton/rustc-demangle/blob/master/src/v0.rs#L552">https://github.com/alexcrichton/rustc-demangle/blob/master/src/v0.rs#L552</a></p>



<a name="207131679"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Adding%20Rust%20v0%20demangling%20support%20to%20LLVM/near/207131679" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Adding.20Rust.20v0.20demangling.20support.20to.20LLVM.html#207131679">(Aug 17 2020 at 11:24)</a>:</h4>
<p>so presumably we can do something similar. <em>however</em>, note that this doesn't allow building an AST of any kind</p>



<a name="207131693"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Adding%20Rust%20v0%20demangling%20support%20to%20LLVM/near/207131693" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Adding.20Rust.20v0.20demangling.20support.20to.20LLVM.html#207131693">(Aug 17 2020 at 11:25)</a>:</h4>
<p>if you want introspection, I need some direction on what that should look like</p>



<a name="207131803"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Adding%20Rust%20v0%20demangling%20support%20to%20LLVM/near/207131803" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Adding.20Rust.20v0.20demangling.20support.20to.20LLVM.html#207131803">(Aug 17 2020 at 11:26)</a>:</h4>
<p>also, what style of error handling is preferred: the Rust code uses <code>?</code> which could be a macro in C++, while the C code does something cruder with an error flag in the state struct which is checked at the start of functions to skip them</p>



<a name="207131944"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Adding%20Rust%20v0%20demangling%20support%20to%20LLVM/near/207131944" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Adding.20Rust.20v0.20demangling.20support.20to.20LLVM.html#207131944">(Aug 17 2020 at 11:28)</a>:</h4>
<p><span class="user-mention" data-user-id="199555">@Petr Hosek</span> <span class="user-mention" data-user-id="304321">@Yifei Teng</span> I'll note that it took me less than a day to convert the Rust version into the C one so that's not as much of a problem as the cost of getting the API wrong and having to redo it, or maintaining it, but hopefully the C++ version can be at least as easy as the C one to backport features to, and hopefully it's portable enough for non-LLVM C++ users to be able to reuse it. but maybe not, and AFAIK all other upstreaming targets use C and currently have an old copy of the legacy demangler from libiberty</p>



<a name="207131971"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Adding%20Rust%20v0%20demangling%20support%20to%20LLVM/near/207131971" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Adding.20Rust.20v0.20demangling.20support.20to.20LLVM.html#207131971">(Aug 17 2020 at 11:29)</a>:</h4>
<p>oh and presumably you'd need a C++ version of this too <a href="https://github.com/alexcrichton/rustc-demangle/blob/master/src/legacy.rs">https://github.com/alexcrichton/rustc-demangle/blob/master/src/legacy.rs</a></p>



<a name="207131979"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Adding%20Rust%20v0%20demangling%20support%20to%20LLVM/near/207131979" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Adding.20Rust.20v0.20demangling.20support.20to.20LLVM.html#207131979">(Aug 17 2020 at 11:29)</a>:</h4>
<p>but thankfully that's tiny by comparison</p>



<a name="207132063"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Adding%20Rust%20v0%20demangling%20support%20to%20LLVM/near/207132063" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Adding.20Rust.20v0.20demangling.20support.20to.20LLVM.html#207132063">(Aug 17 2020 at 11:30)</a>:</h4>
<p>good UTF-8 support helps, I had to handcraft codepoint -&gt; UTF-8 encoding in the C version. punycode already somewhere in the codebase would also be neat (but I guess less portable)</p>



<a name="207132102"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Adding%20Rust%20v0%20demangling%20support%20to%20LLVM/near/207132102" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Adding.20Rust.20v0.20demangling.20support.20to.20LLVM.html#207132102">(Aug 17 2020 at 11:31)</a>:</h4>
<p>oh and make sure this works for you <a href="https://github.com/alexcrichton/rustc-demangle#license">https://github.com/alexcrichton/rustc-demangle#license</a></p>



<a name="207132291"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Adding%20Rust%20v0%20demangling%20support%20to%20LLVM/near/207132291" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Adding.20Rust.20v0.20demangling.20support.20to.20LLVM.html#207132291">(Aug 17 2020 at 11:34)</a>:</h4>
<p><span class="user-mention" data-user-id="199555">@Petr Hosek</span> <span class="user-mention" data-user-id="304321">@Yifei Teng</span> sorry for not coming to this conclusion earlier, I had no idea C++ was non-negotiable (in which case a conversion from C would be the worse path to take <em>no matter who does it</em> - and you're overestimating the importance of you doing it instead of me). also, please PM me if I don't see a reply here. and I <em>really</em> don't have the bandwidth for using a mailing list, I can barely keep up with all of the other stuff that's ten times easier, so please do not insist on me writing emails</p>



<a name="207132328"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Adding%20Rust%20v0%20demangling%20support%20to%20LLVM/near/207132328" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Adding.20Rust.20v0.20demangling.20support.20to.20LLVM.html#207132328">(Aug 17 2020 at 11:34)</a>:</h4>
<p>I hope I listed out everything that should be relevant above</p>



<a name="207132336"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Adding%20Rust%20v0%20demangling%20support%20to%20LLVM/near/207132336" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Adding.20Rust.20v0.20demangling.20support.20to.20LLVM.html#207132336">(Aug 17 2020 at 11:35)</a>:</h4>
<p>although it might not matter until we better figure what we do with constants</p>



<a name="207144798"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Adding%20Rust%20v0%20demangling%20support%20to%20LLVM/near/207144798" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Adding.20Rust.20v0.20demangling.20support.20to.20LLVM.html#207144798">(Aug 17 2020 at 13:39)</a>:</h4>
<p><span class="user-mention" data-user-id="119009">@eddyb</span> my plan was to get the pattern PR merged, then extract a const -&gt; valtree conversion from the const -&gt; pat conversion by creating a trivial valtree -&gt; pat conversion. In parallel to that I'm refactoring to split ty::Const and mir::Const</p>



<a name="207144934"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Adding%20Rust%20v0%20demangling%20support%20to%20LLVM/near/207144934" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Adding.20Rust.20v0.20demangling.20support.20to.20LLVM.html#207144934">(Aug 17 2020 at 13:40)</a>:</h4>
<p>okay I guess we can block on that</p>



<a name="207997938"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Adding%20Rust%20v0%20demangling%20support%20to%20LLVM/near/207997938" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Adding.20Rust.20v0.20demangling.20support.20to.20LLVM.html#207997938">(Aug 25 2020 at 17:57)</a>:</h4>
<p><span class="user-mention" data-user-id="199555">@Petr Hosek</span> <span class="user-mention" data-user-id="304321">@Yifei Teng</span> sorry for not checking in sooner, any updates on the requirements of the C++ version? I would like to be able to tackle that if I get some downtime from other things</p>



<a name="207998020"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Adding%20Rust%20v0%20demangling%20support%20to%20LLVM/near/207998020" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Adding.20Rust.20v0.20demangling.20support.20to.20LLVM.html#207998020">(Aug 25 2020 at 17:58)</a>:</h4>
<p>the const stuff can be added in later without much effort, so there's not much of a strong dependency there</p>



<a name="221327344"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Adding%20Rust%20v0%20demangling%20support%20to%20LLVM/near/221327344" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Adding.20Rust.20v0.20demangling.20support.20to.20LLVM.html#221327344">(Jan 01 2021 at 00:43)</a>:</h4>
<p><span class="user-mention" data-user-id="119009">@eddyb</span> I can ping one of  them on this, but I'm not sure what needs to be cleared up.. it sounds like someone needs to write a pure C++ version using LLVM standards</p>



<a name="221327736"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Adding%20Rust%20v0%20demangling%20support%20to%20LLVM/near/221327736" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Steven Fackler <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Adding.20Rust.20v0.20demangling.20support.20to.20LLVM.html#221327736">(Jan 01 2021 at 00:54)</a>:</h4>
<p>There's a C implementation bundled with perf in the linux source tree that dtolnay wrote a while ago</p>



<a name="221327803"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Adding%20Rust%20v0%20demangling%20support%20to%20LLVM/near/221327803" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Adding.20Rust.20v0.20demangling.20support.20to.20LLVM.html#221327803">(Jan 01 2021 at 00:56)</a>:</h4>
<p>The problem is, it doesn't sound like LLVM wants a C version</p>



<a name="221327822"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Adding%20Rust%20v0%20demangling%20support%20to%20LLVM/near/221327822" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Adding.20Rust.20v0.20demangling.20support.20to.20LLVM.html#221327822">(Jan 01 2021 at 00:57)</a>:</h4>
<p>or at least, they'd want to rewrite it as idiomatic C++ at some point</p>



<a name="221327915"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Adding%20Rust%20v0%20demangling%20support%20to%20LLVM/near/221327915" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Adding.20Rust.20v0.20demangling.20support.20to.20LLVM.html#221327915">(Jan 01 2021 at 00:59)</a>:</h4>
<p>but I'm not sure if it's a hard requirement or not. maybe an email to llvm-dev could clear some things up.</p>



<a name="233539617"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Adding%20Rust%20v0%20demangling%20support%20to%20LLVM/near/233539617" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tm <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Adding.20Rust.20v0.20demangling.20support.20to.20LLVM.html#233539617">(Apr 07 2021 at 18:33)</a>:</h4>
<p>I wrote <a href="https://reviews.llvm.org/D99981">https://reviews.llvm.org/D99981</a>, and have a follow up patch to lldb.</p>



<a name="233541309"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Adding%20Rust%20v0%20demangling%20support%20to%20LLVM/near/233541309" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Adding.20Rust.20v0.20demangling.20support.20to.20LLVM.html#233541309">(Apr 07 2021 at 18:45)</a>:</h4>
<p><span class="user-mention silent" data-user-id="243558">Steven Fackler</span> <a href="#narrow/stream/122651-general/topic/Adding.20Rust.20v0.20demangling.20support.20to.20LLVM/near/221327736">said</a>:</p>
<blockquote>
<p>There's a C implementation bundled with perf in the linux source tree that dtolnay wrote a while ago</p>
</blockquote>
<p>That one doesn't actually get called: it will first try the libiberty demangler which has v0 Rust demangling support.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>